# RT-Thread building script for component

from building import *

cwd     = GetCurrentDir()
src     = []
path    = [cwd]
path   += [cwd + '/on-chip_drivers']

if GetDepend(['BSP_USING_GPIO', 'RT_USING_PIN']):
    src += ['on-chip_drivers/drv_gpio.c']
	
if GetDepend('RT_USING_SERIAL'):
    src += ['on-chip_drivers/drv_usart.c']
    
if GetDepend('RT_USING_ADC'):
    src += ['on-chip_drivers/drv_adc.c']

if GetDepend('RT_USING_DAC'):
    src += ['on-chip_drivers/drv_dac.c']    
    
if GetDepend(['BSP_USING_ETH', 'RT_USING_LWIP']):
    src += ['on-chip_drivers/drv_eth.c']
    
if GetDepend('BSP_USING_I2C'):
    src += ['on-chip_drivers/drv_soft_i2c.c']          

if GetDepend('BSP_USING_SPI'):
    src += ['on-chip_drivers/drv_spi.c'] 
    
if GetDepend('BSP_USING_SPI_FLASH'):
	src += ['on-chip_drivers/drv_spi_flash.c']

if GetDepend(['BSP_USING_FLASH']):
    src += ['on-chip_drivers/drv_flash.c']
        
if GetDepend('BSP_USING_IWDT'):
    src += ['on-chip_drivers/drv_iwdt.c']
    
if GetDepend('BSP_USING_RTC'):
    src += ['on-chip_drivers/drv_rtc.c']
    
if GetDepend('RT_USING_SDIO'):
    src += ['on-chip_drivers/drv_sdio.c']

if GetDepend('BSP_USING_SRAM'):
    src += ['on-chip_drivers/drv_sram.c']	
    
if GetDepend('BSP_USING_PWM'):
    src += ['on-chip_drivers/drv_pwm.c']
    
if GetDepend('BSP_USING_HWTIMER'):
    src += ['on-chip_drivers/drv_hwtimer.c']

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path)

objs = [group]

list = os.listdir(cwd)

for item in list:
    if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
        objs = objs + SConscript(os.path.join(item, 'SConscript'))

Return('objs')
